import requests

weatherUrl = "http://wthrcdn.etouch.cn/weather_mini?city="  # 返回json数据

cityName = input("请输入你要查询的城市：")

weatherJson = requests.get(weatherUrl + cityName)
weatherAll = weatherJson.json()
# print(weatherAll)
if (weatherAll['status'] >= 1000):
    print("城市：", weatherAll["data"]["city"])
    print("-----------------------------------------------------")
    for i in range(len(weatherAll["data"]["forecast"])):
        print("时间：", weatherAll["data"]["forecast"][i]["date"])
        print("温度：", weatherAll["data"]["forecast"][i]["high"], weatherAll["data"]["forecast"][i]["low"])
        print("天气：", weatherAll["data"]["forecast"][i]["type"])
        print("-----------------------------------------------------")
else:
    print("查询错误")
